$(function (){
	validata();
	btnClick();
});

function btnClick(){
	$("#submitForm").click(function (){
		$("#validForm").submit();
	});
	
	$("#showMenuTree").click(function (){
		window.parent.window.hideLayer(window.parent.window.getSingleCheckMenuTreeParentIndex());
		var menuId = $("#menuId").val();
		var index = RM.open("菜单树","showSingleCheckMenuTree.do?menuId=" + menuId,400,600,function (){
			window.parent.window.showSingleCheckMenuTreeParent();
		});
		window.parent.window.setSingleCheckMenuTree(index);
	});
}

function validata(){
	$("#validForm").validate({
	 	submitHandler: function() {
	 		var params = $("#validForm").serialize();
			RM.ajax("/system/button/save.do", params,function (data){
				RM.msg(data.message);
				if(data.code == 0){
					parent.layer.close(window.parent.window.getSingleCheckMenuTreeParentIndex());
				}
			});
		}
	});
}